//
//  YSReadBookModel.m
//  YSBookRead
//
//  Created by Kyson on 2018/11/6.
//  Copyright © 2018 YangShen. All rights reserved.
//

#import "YSReadBookModel.h"

@implementation YSReadBookModel

+ (instancetype)readBookWithBookID:(NSString *)bookID {
    YSReadBookModel *readBook = [[YSReadBookModel alloc] init];
    readBook.bookID = bookID;
    return readBook;
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
    [aCoder encodeObject:self.bookID forKey:@"bookID"];
    [aCoder encodeObject:self.bookName forKey:@"bookName"];
    [aCoder encodeBool:self.isLocalBook forKey:@"isLocalBook"];
    [aCoder encodeBool:self.isHaveUpdated forKey:@"isHaveUpdated"];

    [aCoder encodeObject:self.bookMarkList forKey:@"bookMarkList"];
    [aCoder encodeObject:self.readMarkModel forKey:@"readMarkModel"];
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super init]) {
        self.bookID          = [aDecoder decodeObjectForKey:@"bookID"];
        self.bookName        = [aDecoder decodeObjectForKey:@"bookName"];
        self.isLocalBook     = [aDecoder decodeBoolForKey:@"isLocalBook"];
        self.isHaveUpdated   = [aDecoder decodeBoolForKey:@"isHaveUpdated"];

        self.bookMarkList    = [aDecoder decodeObjectForKey:@"bookMarkList"];
        self.readMarkModel   = [aDecoder decodeObjectForKey:@"readMarkModel"];
    }
    return self;
}

@end
